matrix  g_SkyboxInvWVP;
texture  g_txCubeMap;
samplerCUBE g_samCubeMap = 
sampler_state
{
    Texture = <g_txCubeMap>;
    MinFilter = Linear;
    MagFilter = Linear;
    MipFilter = Linear;
	AddressU  = Clamp;
	AddressV  = Clamp;
	AddressW  = Clamp;
};

//Cubemap input is the screen coordinate ,inverse the mvp to ge the original point.
void RenderCubeMapVert(float4 Pos:POSITION,
					   out float4 oPos:POSITION,
					   out float3 oTex:TEXCOORD0)
{
	oPos = Pos;
    oTex = normalize( mul(Pos, g_SkyboxInvWVP) );
}
void RenderCubeMapPixel(float3 tex:TEXCOORD0,
						out float4 color:COLOR0)
{
	color = texCUBE(g_samCubeMap, tex);
}



technique RenderCubeMap
{
	pass p0
	{
		VertexShader = compile vs_3_0 RenderCubeMapVert();
		PixelShader  = compile ps_3_0 RenderCubeMapPixel();
	}
}